package com.ruoyi.marketers.service.impl;

import java.util.List;

import com.ruoyi.common.core.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.marketers.mapper.ApplyMapper;
import com.ruoyi.marketers.domain.Apply;
import com.ruoyi.marketers.service.IApplyService;

/**
 * 商家审核Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-10-16
 */
@Service
public class ApplyServiceImpl implements IApplyService 
{
    @Autowired
    private ApplyMapper applyMapper;

    /**
     * 查询商家审核
     * 
     * @param applyId 商家审核主键
     * @return 商家审核
     */
    @Override
    public Apply selectApplyByApplyId(Long applyId)
    {
        return applyMapper.selectApplyByApplyId(applyId);
    }

    /**
     * 查询商家审核列表
     * 
     * @param apply 商家审核
     * @return 商家审核
     */
    @Override
    public List<Apply> selectApplyList(Apply apply)
    {
        return applyMapper.selectApplyList(apply);
    }

    /**
     * 新增商家审核
     * 
     * @param apply 商家审核
     * @return 结果
     */
    @Override
    public int insertApply(Apply apply)
    {
        Apply apply1 = applyMapper.selectApplyByApplyId(apply.getApplyId());
        System.out.println(apply1);
        if (apply1!=null&& StringUtils.isNotNull(apply1)){
            return applyMapper.updateApply(apply);
        }else {
            return applyMapper.insertApply(apply);
        }
    }

    /**
     * 修改商家审核
     * 
     * @param apply 商家审核
     * @return 结果
     */
    @Override
    public int updateApply(Apply apply)
    {
        return applyMapper.updateApply(apply);
    }

    /**
     * 批量删除商家审核
     * 
     * @param applyIds 需要删除的商家审核主键
     * @return 结果
     */
    @Override
    public int deleteApplyByApplyIds(Long[] applyIds)
    {
        return applyMapper.deleteApplyByApplyIds(applyIds);
    }

    /**
     * 删除商家审核信息
     * 
     * @param applyId 商家审核主键
     * @return 结果
     */
    @Override
    public int deleteApplyByApplyId(Long applyId)
    {
        return applyMapper.deleteApplyByApplyId(applyId);
    }

    @Override
    public Apply selectApplyByMerchantName(String shopUser) {
        return applyMapper.selectApplyByMerchantName(shopUser);
    }
}
